/*
 * ipassbook 0.6.0
 * Copyright (C)2009 wateray and contributors
 * wateray@gmail.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package com.wateray.ipassbook.kernel.event;

/**
 * @author wateray
 * @create 2009-5-15
 */
public enum IPassbookEventType {

	/** SubjectEvent. */
	SubjectTableChangeEvent,SubjectTableAddEvent,SubjectTableUpdateEvent,SubjectTableDeleteEvent,

	/** passbook. */
	PassbookTableChangeEvent, PassbookTableAddEvent, PassbookTableModifyEvent, PassbookTableDELETEEvent,

	
	/** ReceiptChangeEvent.*/
	ReceiptTableChangeEvent,ReceiptTableAndEvent,ReceiptTableModifyEvent,ReceiptTableDeleteEvent,
	
	/** TansferChangeEvent.*/
	TansferChangeEvent,TansferAndEvent,TansferModifyEvent,TansferDeleteEvent,
	
	XEventType;
	/**
	 * eg. If
	 * <b>SubjectAddEvent</b>,<b>SubjectUpdateEvent</b>,<b>SubjectDeleteEvent
	 * </b> is fired, then a <b>SubjectChangeEvent</b> will be fired. will
	 * 
	 * @param
	 * */
	public boolean isAlso(IPassbookEventType aEventType) {
		if (aEventType == IPassbookEventType.SubjectTableChangeEvent) {
			switch (this) {
			case SubjectTableChangeEvent:
				return true;
			case SubjectTableAddEvent:
				return true;
			case SubjectTableUpdateEvent:
				return true;
			case SubjectTableDeleteEvent:
				return true;
			default:
				return false;
			}
		}
		
		if (aEventType == IPassbookEventType.PassbookTableChangeEvent) {
			switch (this) {
			case PassbookTableChangeEvent:
				return true;
			case PassbookTableAddEvent:
				return true;
			case PassbookTableModifyEvent:
				return true;
			case PassbookTableDELETEEvent:
				return true;
			default:
				return false;
			}
		}
		
		if (aEventType == IPassbookEventType.ReceiptTableChangeEvent) {
			switch (this) {
			case ReceiptTableChangeEvent:
				return true;
			case ReceiptTableAndEvent:
				return true;
			case ReceiptTableModifyEvent:
				return true;
			case ReceiptTableDeleteEvent:
				return true;
			default:
				return false;
			}
		}
		
		if (aEventType == IPassbookEventType.TansferChangeEvent) {
			if(this.toString().startsWith("Tansfer")){
				return true;
			}
		}
		
		return false;
	}

}
